<?php

namespace App\Http\Controllers\Admins;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;

class ConfigController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function getIndex()
    {
        $res = DB::table('config')->first();
        
        // dd($res);die;



        return view('webadmin.config.index',[
                'res' => $res
            ]);
    }

    public function postUpdate(Request $request)
    {
        $dirname = './logo/';
        $filename = $request->file('logo')->getClientOriginalName();
        $filename = time().rand(100000,999999).'.'.$filename;
        $request->file('logo')->move($dirname,$filename);
        $logo = ltrim($dirname.$filename,'.');
        $data = [];
        $data['title'] = $request->title;
        $data['logo'] = $logo;
        $data['keywords'] = $request->keywords;
        $data['status'] = $request->button;
        DB::table('config')->update($data);
        return redirect('/admin/config');
    }
}
